Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Upgrade Support for Standby Cluster #830

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Conversation

vitabaks
Copy link
Owner

@vitabaks vitabaks commented Dec 6, 2024

We have now automated the upgrade process for the Patroni Standby Cluster. This allows us to perform upgrades on the cluster copy without impacting the main cluster.

However, this approach requires a preliminary (manual) stop of traffic to the main cluster to ensure no recent data changes are lost.

P.S. A zero-downtime upgrade using the blue/green strategy is planned as part of issue and will be included in one of the future versions of Autobase.

@vitabaks vitabaks added the enhancement Improvement of the current functionality label Dec 6, 2024
@vitabaks vitabaks self-assigned this Dec 6, 2024
@vitabaks
Copy link
Owner Author

vitabaks commented Dec 6, 2024

Test: Upgrade Standby Cluster

...

PLAY [(4/6) PRE-UPGRADE: Prepare the Patroni configuration] ********************

TASK [Include main variables] **************************************************
ok: [10.172.2.20]
ok: [10.172.2.21]
ok: [10.172.2.22]

TASK [Include OS-specific variables] *******************************************
ok: [10.172.2.20]
ok: [10.172.2.21]
ok: [10.172.2.22]

TASK [Include upgrade variables] ***********************************************
ok: [10.172.2.20]
ok: [10.172.2.21]
ok: [10.172.2.22]

TASK [Patroni config] **********************************************************

TASK [upgrade : Backup the patroni.yml configuration file] *********************
changed: [10.172.2.20]
changed: [10.172.2.22]
changed: [10.172.2.21]

TASK [upgrade : Remove patroni.dynamic.json file] ******************************
changed: [10.172.2.20]
changed: [10.172.2.22]
changed: [10.172.2.21]

TASK [upgrade : Edit patroni.yml | update parameters: data_dir, bin_dir, config_dir] ***
changed: [10.172.2.20] => (item=data_dir: /pgdata/17/main)
changed: [10.172.2.22] => (item=data_dir: /pgdata/17/main)
changed: [10.172.2.21] => (item=data_dir: /pgdata/17/main)
changed: [10.172.2.20] => (item=bin_dir: /usr/lib/postgresql/17/bin)
changed: [10.172.2.22] => (item=bin_dir: /usr/lib/postgresql/17/bin)
changed: [10.172.2.21] => (item=bin_dir: /usr/lib/postgresql/17/bin)
changed: [10.172.2.21] => (item=config_dir: /etc/postgresql/17/main)
changed: [10.172.2.22] => (item=config_dir: /etc/postgresql/17/main)
changed: [10.172.2.20] => (item=config_dir: /etc/postgresql/17/main)

TASK [upgrade : Edit patroni.yml | check if the 'db_user_namespace' parameter is specified] ***
ok: [10.172.2.20]
ok: [10.172.2.22]
ok: [10.172.2.21]

TASK [upgrade : Edit patroni.yml | check if the 'old_snapshot_threshold' parameter is specified] ***
ok: [10.172.2.21]
ok: [10.172.2.20]
ok: [10.172.2.22]

TASK [upgrade : Edit patroni.yml | check if the 'trace_recovery_messages' parameter is specified] ***
ok: [10.172.2.20]
ok: [10.172.2.21]
ok: [10.172.2.22]

TASK [upgrade : Edit patroni.yml | remove parameter: standby_cluster (if exists)] ***
changed: [10.172.2.20]
changed: [10.172.2.21]
changed: [10.172.2.22]

TASK [upgrade : Remove 'standby_cluster' parameter from DCS (if exists)] *******
changed: [10.172.2.20]

TASK [upgrade : Copy pg_hba.conf to /etc/postgresql/17/main] *******************
changed: [10.172.2.20]
changed: [10.172.2.21]
changed: [10.172.2.22]
...

TASK [upgrade : List the Patroni cluster members] ******************************
ok: [10.172.2.20] => {
    "msg": [
        "+ Cluster: postgres-cluster (7445324859738221435) --+-----------+",
        "| Member   | Host        | Role    | State     | TL | Lag in MB |",
        "+----------+-------------+---------+-----------+----+-----------+",
        "| pgnode01 | 10.172.2.20 | Leader  | running   |  2 |           |",
        "| pgnode02 | 10.172.2.21 | Replica | streaming |  2 |         0 |",
        "| pgnode03 | 10.172.2.22 | Replica | streaming |  2 |         0 |",
        "+----------+-------------+---------+-----------+----+-----------+"
    ]
}

TASK [upgrade : Upgrade completed] *********************************************
ok: [10.172.2.20] => {
    "msg": [
        "PostgreSQL upgrade completed.",
        "Current version: 17.2 (Ubuntu 17.2-1.pgdg22.04+1)"
    ]
}
  • Remove patroni.dynamic.json file
  • Edit patroni.yml | remove parameter: standby_cluster
  • Remove 'standby_cluster' parameter from DCS

passed

@vitabaks vitabaks merged commit 03157f7 into master Dec 6, 2024
15 checks passed
@vitabaks vitabaks deleted the standby-cluster-upgrade branch December 6, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of the current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant